package com.weipt.service;

import net.bytebuddy.implementation.bind.annotation.Empty;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author weipt
 * @description 绑定关系，基于消费者注解完成
 * @date 2024/1/11 22:03
 */
@Service
public class TopicConsumer {

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "email-topic-queue", durable="true", autoDelete = "false"),
            exchange = @Exchange(value = "topic-exchange-springboot", type = ExchangeTypes.TOPIC),
            key = "#.email.#"
    ))
    public void reviceEmailMsg(String message){
        System.out.println("email消费者收到消息："+message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "sms-topic-queue", durable="true", autoDelete = "false"),
            exchange = @Exchange(value = "topic-exchange-springboot", type = ExchangeTypes.TOPIC),
            key = "#.sms.#"
    ))
    public void reviceSmsMsg(String message){
        System.out.println("sms消费者收到消息："+message);
    }

    @RabbitListener(bindings = @QueueBinding(
            value = @Queue(value = "msg-topic-queue", durable="true", autoDelete = "false"),
            exchange = @Exchange(value = "topic-exchange-springboot", type = ExchangeTypes.TOPIC),
            key = "#.msg.#"
    ))
    public void revicMsgMsg(String message){
        System.out.println("msg消费者收到消息："+message);
    }
}
